package com.interview.service.impl;

import com.interview.entity.WaitingRoomInfo;
import com.interview.mapper.WaitingRoomInfoMapper;
import com.interview.service.WaitingRoomInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class WaitingRoomInfoServiceImpl implements WaitingRoomInfoService {
    @Autowired
    private WaitingRoomInfoMapper waitingRoomInfoMapper;

    @Override
    public WaitingRoomInfo getOneWaitingRoomInfo() {
        WaitingRoomInfo waitingRoomInfo = waitingRoomInfoMapper.selectOne(null);
        return waitingRoomInfo;
    }

    @Transactional
    @Override
    public int addWaitingRoomInfo(WaitingRoomInfo waitingRoomInfo) {

        return waitingRoomInfoMapper.insert(waitingRoomInfo);
    }

    @Override
    public boolean checkDataExist() {
        List<WaitingRoomInfo> waitingRoomInfos = waitingRoomInfoMapper.selectList(null);
        if (waitingRoomInfos != null && waitingRoomInfos.size() > 0) {
            return true;
        }else {
            return false;
        }
    }

}
